package com.aspose.cells.a.d;

import com.aspose.cells.Color;

public class zar implements Cloneable {
   private zcb b;
   private com.aspose.cells.b.a.b.zq c;
   private int d;
   private int e;
   private Color f;
   private Color g;
   private int h;
   private int i;
   private int j;
   private int k;
   private int l;
   private int m;
   private int n;
   private int o;
   private int p;
   private int q;
   private int r;
   private int s;
   private int t;
   public com.aspose.cells.b.a.b.a.zi a;
   private com.aspose.cells.b.a.b.a.zi u;
   private zbt v;
   private zbp w;
   private zbr x;
   private com.aspose.cells.b.a.b.zm y;
   private com.aspose.cells.b.a.b.zc z;
   private zav A;
   private com.aspose.cells.b.a.b.zt B;
   private boolean C;
   private float D;
   private float E;
   private long[] F;

   public zar(zcb var1) throws Exception {
      this.b = var1;
      this.b();
   }

   public void a(long var1) throws Exception {
      zbh var3 = this.b.g().a(var1);
      if (var3 == null) {
         throw new Exception(com.aspose.cells.b.a.zv.a("No Gdi object for handle {0}=0x{1:x}", var1, var1));
      } else {
         switch(var3.a()) {
         case 1:
            this.w = (zbp)com.aspose.cells.b.a.zl.a(var3, zbp.class);
            this.u();
            break;
         case 2:
            this.v = (zbt)com.aspose.cells.b.a.zl.a(var3, zbt.class);
            this.y = null;
            break;
         case 3:
         case 4:
         case 5:
         case 7:
         case 8:
         case 9:
         default:
            throw new IllegalStateException("Unknown GDI object type.");
         case 6:
            this.x = (zbr)com.aspose.cells.b.a.zl.a(var3, zbr.class);
            this.A = null;
         case 10:
         case 11:
         }

      }
   }

   public void a(com.aspose.cells.b.a.b.zo var1) {
      this.c.a(var1);
   }

   public void a(com.aspose.cells.b.a.b.zt var1) {
      this.c.a(var1);
      this.C = true;
   }

   public void b(com.aspose.cells.b.a.b.zt var1) {
      this.B = d(var1);
   }

   public zar a() {
      zar var1 = (zar)this.t();
      if (this.a != null) {
         var1.a = this.a.b();
      }

      if (this.u != null) {
         var1.u = this.u.b();
      }

      return var1;
   }

   private float c(com.aspose.cells.b.a.b.zt var1) {
      switch(6 & this.h) {
      case 2:
         return var1.b();
      case 6:
         return var1.b() / 2.0F;
      default:
         return 0.0F;
      }
   }

   private float a(zav var1) {
      switch(24 & this.h) {
      case 0:
         return var1.h();
      case 8:
         return -var1.i();
      default:
         return 0.0F;
      }
   }

   public com.aspose.cells.b.a.b.a.zi a(com.aspose.cells.b.a.b.zo[] var1, com.aspose.cells.b.a.b.zt var2, zav var3) {
      com.aspose.cells.b.a.b.a.zi var4 = new com.aspose.cells.b.a.b.a.zi();
      var4.b(-this.c(var2), this.a(var3));
      float[] var5 = var4.e();
      float[] var6 = new float[]{Math.signum(var5[0]), Math.signum(var5[3]), Math.signum(var5[4]), Math.signum(var5[5])};
      var6[2] = var6[0] < 0.0F ? var6[2] : 1.0F;
      var6[3] = var6[1] < 0.0F ? var6[3] : 1.0F;
      var1[0] = new com.aspose.cells.b.a.b.zo(var6[0] * var1[0].d(), var6[1] * var1[0].e());
      var4 = new com.aspose.cells.b.a.b.a.zi(var6[0] * var5[0], var5[1], var5[2], var6[1] * var5[3], var6[2] * var5[4], var6[3] * var5[5]);
      var4.a(-this.x.e(), new com.aspose.cells.b.a.b.zo(var1[0].d(), var1[0].e() + this.a(var3)));
      return var4;
   }

   public void b() throws Exception {
      this.c = zaq.a();
      this.d = 2;
      this.e = 8;
      this.f = Color.getWhite();
      this.g = Color.getBlack();
      this.h = 0;
      this.i = 0;
      this.j = 1;
      this.k = 1;
      this.l = 3;
      this.m = 0;
      this.n = 1;
      this.o = 0;
      this.p = 0;
      this.q = 0;
      this.s = 4;
      this.t = 1;
      this.a = new com.aspose.cells.b.a.b.a.zi();
      this.v = new zbt();
      this.w = new zbp();
      this.x = new zbr();
      this.y = new com.aspose.cells.b.a.b.zm(this.g);
      this.y.c(2);
      this.y.d(2);
      this.y.e(2);
      this.z = new com.aspose.cells.b.a.b.zu(this.f);
      this.A = zav.a("Microsoft Sans Serif", 12.0F, 0);
      this.B = zaq.b();
      this.C = false;
      this.D = 1.0F;
      this.E = 1.0F;
   }

   private void u() {
      if (this.w != null && this.w.c() == 2 || this.w.c() == 240) {
         this.w.b(this.h() == 2 ? this.f : Color.getEmpty());
      }

      this.z = null;
   }

   public com.aspose.cells.b.a.b.zm c() throws Exception {
      if (this.y == null) {
         this.y = this.v.a(this.g());
      }

      return this.y;
   }

   public com.aspose.cells.b.a.b.zc d() {
      if (this.z == null) {
         com.aspose.cells.b.a.b.a.zi var1 = new com.aspose.cells.b.a.b.a.zi();
         switch(this.b.c().m()) {
         case 2:
            float var2 = this.b.c().g() / 96.0F;
            var1.a(var2, var2);
            this.z = this.w.a(var1);
            break;
         default:
            var1.a(1.0F / this.p().e()[0], 1.0F / this.p().e()[3]);
         }

         this.z = this.w.a(var1);
      }

      return this.z;
   }

   public zav e() throws Exception {
      if (this.A == null) {
         this.A = this.x.c();
      }

      return this.A;
   }

   public com.aspose.cells.b.a.b.zq f() {
      return this.c;
   }

   public Color g() {
      return this.d == 1 ? Color.a(0, (Color)this.f) : this.f;
   }

   public void a(Color var1) {
      this.f = var1;
      this.u();
   }

   public int h() {
      return this.d;
   }

   public void a(int var1) {
      this.d = var1;
      this.u();
   }

   public Color i() {
      return this.g;
   }

   public void b(Color var1) {
      this.g = var1;
   }

   public int j() {
      return this.h;
   }

   public void b(int var1) {
      this.h = var1;
   }

   public void c(int var1) {
      this.e = var1;
      this.B = zaq.b();
      this.C = false;
   }

   public int k() {
      return this.j;
   }

   public void d(int var1) {
      this.j = var1;
   }

   public void e(int var1) {
      this.k = var1;
   }

   public void f(int var1) {
      this.l = var1;
   }

   public int l() {
      return this.i;
   }

   public void g(int var1) {
      this.i = var1;
   }

   public int m() {
      return this.r;
   }

   public void h(int var1) {
      this.r = var1;
   }

   public com.aspose.cells.b.a.b.a.zi n() {
      if (this.u == null) {
         this.o();
      }

      return this.u;
   }

   public void o() {
      this.u = new com.aspose.cells.b.a.b.a.zi();
      float var3 = this.b.c().g() / 72.0F;
      float var4 = this.b.c().h() / 72.0F;
      float var1;
      float var2;
      switch(this.e) {
      case 1:
         break;
      case 2:
         this.u.a(0.28346458F * var3, -0.28346458F * var4);
         break;
      case 3:
         this.u.a(0.028346457F * var3, -0.028346457F * var4);
         break;
      case 4:
         this.u.a(0.71999997F * var3, -0.71999997F * var4);
         break;
      case 5:
         this.u.a(0.072000004F * var3, -0.072000004F * var4);
         break;
      case 6:
         this.u.a(0.05F * var3, -0.05F * var4);
         break;
      case 7:
         this.v();
         if (this.C) {
            com.aspose.cells.b.a.b.zt var5 = d(this.c.e());
            var1 = this.B.b() / var5.b();
            var2 = this.B.c() / var5.c();
            this.u.b(-this.f().f() * var1 + this.b.e().f(), -this.f().g() * var2 + this.b.e().g());
            this.u.a(var1, var2);
         } else {
            this.u.a(0.28346458F * var3, -0.28346458F * var4);
         }
         break;
      case 8:
         this.v();
         var1 = Math.max(this.b.e().h(), 1.0F) / this.c.h();
         var2 = Math.max(this.b.e().i(), 1.0F) / this.c.i();
         this.u.b(-this.f().f() * var1 + this.b.e().f(), -this.f().g() * var2 + this.b.e().g());
         this.u.a(var1, var2);
         break;
      default:
         throw new IllegalStateException("Unknown mapping mode.");
      }

   }

   private void v() {
      if (this.c.h() == 0.0F) {
         this.c.c(1.0F);
      }

      if (this.c.i() == 0.0F) {
         this.c.d(1.0F);
      }

      if (this.b.e().i() == 0.0F) {
         this.b.a(new com.aspose.cells.b.a.b.zq(this.b.e().d(), new com.aspose.cells.b.a.b.zt(this.b.e().h(), 1.0F)));
      }

   }

   public com.aspose.cells.b.a.b.a.zi p() {
      com.aspose.cells.b.a.b.a.zi var1 = this.n().b();
      var1.b(this.a);
      return var1;
   }

   public void a(com.aspose.cells.b.a.b.a.zi var1) {
      this.a = var1;
   }

   public void a(com.aspose.cells.b.a.b.a.zi var1, int var2) {
      switch(var2) {
      case 1:
         this.a = new com.aspose.cells.b.a.b.a.zi();
         break;
      case 2:
         this.a.a((com.aspose.cells.b.a.b.a.zi)var1, 0);
         break;
      case 3:
         this.a.a((com.aspose.cells.b.a.b.a.zi)var1, 1);
         break;
      case 4:
         this.a(var1);
      }

   }

   private static com.aspose.cells.b.a.b.zt d(com.aspose.cells.b.a.b.zt var0) {
      float var1 = Math.abs(var0.b());
      float var2 = Math.abs(var0.c());
      float var3 = var1 < var2 ? var1 : var2;
      var1 = Math.signum(var0.b()) * var3;
      var2 = Math.signum(var0.c()) * var3;
      return new com.aspose.cells.b.a.b.zt(var1, var2);
   }

   public float q() {
      return this.D;
   }

   public void a(float var1) {
      this.D = var1;
   }

   public float r() {
      return this.E;
   }

   public void b(float var1) {
      this.E = var1;
   }

   public long[] s() {
      return this.F;
   }

   public void a(long[] var1) {
      this.F = var1;
   }

   protected Object t() {
      try {
         return this.clone();
      } catch (CloneNotSupportedException var2) {
         throw new IllegalStateException(var2);
      }
   }
}
